package com.rp.common.utils;

import java.util.List;

/**
 * 类说明: 判断是否为空的方法类
 *
 * @author ****
 * @date 2020-12-16 9:58  新建
 */

public class NullIs {

    /**
     * @param object 对象
     * @return boolean true空
     * @Author HuJingYu
     * @Date 9:59 2020-12-16
     * @Description 判断对象是否为空
     */
    public static boolean isEmpty(Object object) {
        if (object == null) {
            return (true);
        }
        if ("".equals(object)) {
            return (true);
        }
        if ("null".equals(object)) {
            return (true);
        }
        return (false);
    }

    /**
     * @param str 字符串
     * @return boolean true空
     * @Author HuJingYu
     * @Date 10:05 2020-12-16
     * @Description 判断对象是否为空
     */
    public static boolean isEmpty(String str) {
        int strLen;
        if (str != null && (strLen = str.length()) != 0) {
            for (int i = 0; i < strLen; ++i) {
                if (!Character.isWhitespace(str.charAt(i))) {
                    return false;
                }
            }
        }
        return true;
    }

    public static boolean isEmpty(List list) {
        if (list == null) {
            return true;
        }
        return list.size() == 0;
    }

    public static boolean isEmpty(Object[] arr) {
        if (arr == null) {
            return true;
        }
        return arr.length == 0;
    }
}
